package com.itcam.interview.pro01javase;

/**
 * @author : Cammy.Wu
 * Description : 
 */

public class Demo08TransmitValueOrRef {

    public static void main(String[] args) {
        Demo08TransmitValueOrRef that = new Demo08TransmitValueOrRef();
        int age = 20;
        that.changeValue1(age);
        System.out.println("age = " + age);

        String str = "old";
        that.changeValue2(str);
        System.out.println("str = " + str);

        Person person = new Person("old");
        // Person(类模板：在方法区里面) person(引用/指针：在栈里面) = new Person("old") （实例对象：在堆里面）;

        that.changeValue3(person);
        System.out.println("person = " + person.getName());

    }

    public void changeValue1(int age) {
        age = 30;
    }

    public void changeValue2(String str) {
        str = "new";
    }

    public void changeValue3(Person person) {
        person.setName("new");
    }
}
